<?php
/* 
 * class.setinfo.php
 * 我的城市首页-商家信息
 * @author samuel
 * @date 2009-05-23
 */
include_once 'class.mycityBase.php';
class mycity_setinfo extends mycityBase {
    private $seller_id;
    private $step;


    function  __construct($core) {
        parent::__construct();
        //参数处理
	    $this->step = $this->params['step'] ? strtolower(trim($core->params['step'])) : 'index';
	    $this->set_id = $this->params['sid'] ? (int)$this->params['sid'] : 0;
	    $this->user_id = $this->params['uid'] ? (int)$this->params['uid'] : 1;
	    if(!$this->user_id){
		    $this->error = "用户ID不合法！";
		    $this->jumpError();
		    exit;
	    }
	    if(!$this->set_id){
		    $this->error = "套餐ID不合法！";
		    $this->jumpError();
		    exit;
	    }

        $run = "run_" . $this->step;
        
        //header("Content-type: text/vnd.wap.wml");
        $this->$run();
    }

    function run_index(){
    	//WAP页面
	    //header("Content-type: text/vnd.wap.wml");
	    //TITLE
	    $page_title = "我的城市-套餐信息";
	    $content = "";
	    $content .= "<a href='./mycity.php?uid=".$this->user_id."' alt='返回上级'>返回上级</a><br/><br/>";
	    
	    $setinfo = $this->getSetInfo($this->set_id);
	    $setPublisher = $this->core->load('user::userBase')->getInfo(array('table'=>'fun_user', 'primary'=>'UserID'), $setinfo['UserID']);
	    $content .= $setinfo['SellerSetNam']."<br/>";
	    $content .= "发布者:" . $setPublisher['UserNickName'] . "<br/>";
	    $content .= "人气:" . $setinfo['Hits'] . "<br/>";
	    
	    $setContents = $this->getSetContent($this->set_id);
	    //var_dump($setContents);
	    if($setContents){
	    $sellerBase = $this->core->load('seller::sellerBase');
	        foreach($setContents as $setContent){
	            $seller = $sellerBase->getSellerInfo($setContent['SellerID']);
	            //var_dump($seller);
	            $content .= "<a href='".$_SERVER['PHP_SELF']."?act=sellerinfo&amp;sid=".$seller['SellerID']."&amp;uid=".$this->user_id."'>".$seller['SellerNameCN']."</a><br/>";
	            $content .= $setContent['SetContent']."<br/>";
	        } 
	    }
	    
	    $content .= "<br/>";
	    $content .= "<a href='".$_SERVER['PHP_SELF']."?act=setinfo&amp;step=hit&amp;sid=".$this->set_id."&amp;uid=".$this->user_id."'>支持</a><br/><br/>";
	    
	    
	
	    $content .= "<a href='./mycity.php?uid=".$this->user_id."' alt='返回上级'>返回上级</a><br/>";
	    $content .= "<a href='' alt='建议帮助'>建议帮助</a>";



	    $this->core->tpl->assign('content', $content);
	    $this->core->tpl->assign('page_title', $page_title);
	    $this->core->tpl->display('comm.wml');
    }
    
    
    function run_hit(){
        $page_title = "我的城市-商家套餐";
    	$backurl = $_SERVER['PHP_SELF'] . '?act=setinfo&sid=' . $this->set_id . '&uid=' . $this->user_id;
        $sql = "UPDATE `fun_seller_set` SET `Hits`=`Hits`+1 WHERE `SellerSetID`='".$this->set_id."'";
        $res = $this->core->db->query($sql);
        if($res){
            $content = "支持成功！";
        }else{
            $content = "支持失败！";
        }

    	$this->jumpPrompt($content, $page_title, $backurl);
    }
}


?>
